<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>app/helpers/application_helper.rb</title>
    <link href="screen.css" media="all" rel="stylesheet" type="text/css" />
    <link href="print.css" media="print" rel="stylesheet" type="text/css" />
    
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <script type="text/javascript" src="rcov.js"></script>
  </head>
  <body>
    <h1>Survey0 3 C0 Coverage Information - RCov</h1>
    <h2>app/helpers/application_helper.rb</h2>

    

    <div class="report_table_wrapper">
      <table class='report' id='report_table'>
        <thead>
          <tr>
            <th class="left_align">Name</th>
            <th class="right_align">Total Lines</th>
            <th class="right_align">Lines of Code</th>
            <th class="left_align">Total Coverage</th>
            <th class="left_align">Code Coverage</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="left_align"><a href="app-helpers-application_helper_rb.html">app/helpers/application_helper.rb</a></td>
            <td class='right_align'><tt>139</tt></td>
            <td class='right_align'><tt>105</tt></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>28.78%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:29px"></div>
            <div class="uncovered" style="width:71px"></div>
          </div></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>11.43%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:11px"></div>
            <div class="uncovered" style="width:89px"></div>
          </div></td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <h3>Key</h3>
    
    <div class="key"><pre><span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here's a line marked as not executed.</span></pre></div>

    <h3>Coverage Details</h3>

    <table class="details">
      <tbody>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line1">1</a> # Methods added to this helper will be available to all templates in the application.</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line2">2</a> require &quot;pp&quot;</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line3">3</a> </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line4">4</a> module ApplicationHelper</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line5">5</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line6">6</a>   #=====================================</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line7">7</a>   #       计算倾向测试的结果</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line8">8</a>   #=====================================</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line9">9</a>   def self.trend_test_result(array)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line10">10</a>     hash = Hash.new</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line11">11</a>     for a in array</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line12">12</a>       count = 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line13">13</a>       for b in array</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line14">14</a>         if a[0] == b[0] then</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line15">15</a>           count += b[1]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line16">16</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line17">17</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line18">18</a>       hash[a[0]] = count</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line19">19</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line20">20</a>     hash.sort {|a, b| b[1] &lt;=&gt; a[1]}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line21">21</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line22">22</a>   </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line23">23</a>   </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line24">24</a>   #验证中文化</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line25">25</a>   def error_messages_for(object_name, options = {})</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line26">26</a>     options = options.symbolize_keys</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line27">27</a>     object = instance_variable_get(&quot;@#{object_name}&quot;)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line28">28</a>     unless object.errors.empty?</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line29">29</a>       error_lis = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line30">30</a>       object.errors.each{ |key, msg| error_lis &lt;&lt; content_tag(&quot;li&quot;, msg) }</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line31">31</a>       content_tag(&quot;div&quot;, content_tag(options[:header_tag] || &quot;h2&quot;,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line32">32</a>           &quot;发生#{object.errors.count}个错误&quot; ) + content_tag(&quot;ul&quot;, error_lis),</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line33">33</a>           &quot;id&quot; =&gt; options[:id] || &quot;errorExplanation&quot;,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line34">34</a>           &quot;class&quot; =&gt; options[:class] || &quot;errorExplanation&quot; )</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line35">35</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line36">36</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line37">37</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line38">38</a>   #验证中文化</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line39">39</a>   def error_messages_for111(object_name, options = {})</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line40">40</a>     options = options.symbolize_keys</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line41">41</a>     object = instance_variable_get(&quot;@#{object_name}&quot;)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line42">42</a>     unless object.errors.empty?</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line43">43</a>       error_lis = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line44">44</a>       object.errors.each{ |key, msg| error_lis &lt;&lt; content_tag(&quot;li&quot;, msg) }</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line45">45</a>       content_tag(&quot;div&quot;, content_tag(&quot;ul&quot;, error_lis),</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line46">46</a>           &quot;id&quot; =&gt; options[:id] || &quot;errorExplanation&quot;,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line47">47</a>           &quot;class&quot; =&gt; options[:class] || &quot;errorExplanation&quot; )</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line48">48</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line49">49</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line50">50</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line51">51</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line52">52</a>   #年龄选择器</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line53">53</a>   def age_select(model, column)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line54">54</a>     array = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line55">55</a>     #array &lt;&lt; [NOT_IMPORT, NOT_IMPORT]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line56">56</a>     for i in 1..100  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line57">57</a>       array &lt;&lt; [i, i]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line58">58</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line59">59</a>     select(model, column, array )</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line60">60</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line61">61</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line62">62</a>   #安全地得到用户的信息</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line63">63</a>   def safe_user_info</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line64">64</a>     current_user_id = session[CURRENT_USER_ID]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line65">65</a>     user = User.find(current_user_id)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line66">66</a>     user.password = &quot;&quot;</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line67">67</a>     user</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line68">68</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line69">69</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line70">70</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line71">71</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line72">72</a>   #覆盖系统的方法，支持把错误信息放到&lt;span&gt;&lt;/span&gt;中</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line73">73</a>   def error_message_on111(tag, object, method, *args)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line74">74</a>     options = args.extract_options!</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line75">75</a>     unless args.empty?</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line76">76</a>       ActiveSupport::Deprecation.warn('error_message_on takes an option hash instead of separate ' +</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line77">77</a>         'prepend_text, append_text, and css_class arguments', caller)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line78">78</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line79">79</a>       options[:prepend_text] = args[0] || ''</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line80">80</a>       options[:append_text] = args[1] || ''</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line81">81</a>       options[:css_class] = args[2] || 'formError'</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line82">82</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line83">83</a>     options.reverse_merge!(:prepend_text =&gt; '', :append_text =&gt; '', :css_class =&gt; 'formError')</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line84">84</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line85">85</a>     if (obj = (object.respond_to?(:errors) ? object : instance_variable_get(&quot;@#{object}&quot;))) &amp;&amp;</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line86">86</a>       (errors = obj.errors.on(method))</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line87">87</a>       content_tag(tag,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line88">88</a>         &quot;#{options[:prepend_text]}#{ERB::Util.html_escape(errors.is_a?(Array) ? errors.first : errors)}#{options[:append_text]}&quot;,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line89">89</a>         :class =&gt; options[:css_class]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line90">90</a>       )</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line91">91</a>     else</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line92">92</a>       ''</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line93">93</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line94">94</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line95">95</a>   </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line96">96</a>   def current_user</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line97">97</a>     if session[CURRENT_USER_ID]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line98">98</a>       @user = User.find(session[CURRENT_USER_ID])</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line99">99</a>       @user.password = ''</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line100">100</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line101">101</a>     @user</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line102">102</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line103">103</a>   </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line104">104</a>   def count_by_formula(number, formula)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line105">105</a>     #如： count_by_formual(2, &quot;*5&quot;) , return =&gt; 2*5=10</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line106">106</a>     eval &quot;#{number}.#{formula[0,1]} #{formula[1, formula.length]}&quot;</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line107">107</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line108">108</a>   </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line109">109</a>   </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line110">110</a>   def find_expl(dimen_id,marks)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line111">111</a>     dimen=Dimen.find_by_id(dimen_id)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line112">112</a>     explanations=dimen.explanations</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line113">113</a>     result=nil</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line114">114</a>     explanations.each do |expl|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line115">115</a>       if  marks.to_i &gt;= expl.start_num &amp;&amp; marks.to_i &lt; expl.end_num </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line116">116</a>         result = expl.description</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line117">117</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line118">118</a>     end </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line119">119</a>     result</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line120">120</a>   end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line121">121</a>   </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line122">122</a>   </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line123">123</a>     def surveys_authorith(id)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line124">124</a>      all_ids=Survey.find_by_sql(&quot;select t1.id from surveys t1, orgs_surveys t2 where t1.id = t2.survey_id and t2.org_id = #{session[CURRENT_USER_ID]} &quot;)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line125">125</a>     surveyids=[]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line126">126</a>     all_ids.each do |s|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line127">127</a>      surveyids &lt;&lt; s.id  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line128">128</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line129">129</a>      if surveyids.include?(id)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line130">130</a>         return true        </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line131">131</a>      else</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line132">132</a>       return false</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line133">133</a>      end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line134">134</a>    end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line135">135</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line136">136</a>   </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line137">137</a> end</pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line138">138</a> </pre></td>
          </tr>
        
          
          
          <tr class="inferred">
            <td><pre><a name="line139">139</a> </pre></td>
          </tr>
        
      </tbody>
    </table>

    <p>Generated on Wed Mar 17 14:12:44 +0800 2010 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>

  </body>
</html>
